package com.zzb.servlet;


import com.zzb.model.CompanyDescriptionModel;
import com.zzb.service.CompanyService;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;


@WebServlet("/company")
public class CompanyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.处理乱码
        req.setCharacterEncoding(StandardCharsets.UTF_8.toString());
        resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());

        //2.得到前端数据

        //3.将数据封装到model

        //4.处理服务逻辑关系
        //顶部导航栏
        //NavigationService navigationService = new NavigationService();
        //公司描述
        CompanyService companyService = new CompanyService();


        //5.得到处理返回值
        //得到导航栏数据
        //List<NavigationModel> navigationModelList = navigationService.getNavigationModel();
        //得到底部公司信息数据
        //CompanyModel companyModel = companyService.getCompanyModel();
        //得到公司描述
        List<CompanyDescriptionModel> companyDescriptionModelList = companyService.getCompanyDescriptionModel();

        //req.setAttribute("navigationModelList", navigationModelList);
        //req.setAttribute("companyModel", companyModel);
        req.setAttribute("companyDescriptionModelList",companyDescriptionModelList );



        //6.将数据返回到前端
        req.getRequestDispatcher("/jsp/company.jsp").forward(req, resp);
    }
}
